package com.base.cn.platform.os.controller.app;

import com.base.cn.platform.os.common.constants.ConfigName;
import com.base.cn.platform.os.controller.cmmon.ApiBaseController;
import com.base.cn.platform.os.service.manage.config.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.TreeMap;

/**
 * @Author zjh
 * @Description // 管理app
 * @Date 2018/11/12 16:11
 */
@Controller
@RequestMapping("/api/app")
public class ManagementAppController extends ApiBaseController {


    @Value("${static.path}")
    private String staticPath;
    @Autowired
    private SysConfigService sysConfigService;


    /**
     * App下载页面
     * @return
     */
    @RequestMapping("/appDownload")
    public String appDownloadPage(HttpServletRequest request){
        TreeMap<String, String> app = sysConfigService.getSysConfigContext(ConfigName.APP);
        TreeMap<String, String> info = sysConfigService.getSysConfigContext(ConfigName.INFO);
        request.setAttribute("title",info.get("appName"));
        request.setAttribute("iosUrl",app.get("iosUrl"));
        request.setAttribute("anUrl",app.get("anUrl"));
        request.setAttribute("staticPath",staticPath);
        return  "/view/app/appDownload";
    }

    /**
     * 跳转到客服页面
     *
     * @return
     */
    @RequestMapping("/customerIndex")
    public String customerIndex(HttpServletRequest request){
        TreeMap<String,String> serviceMap = sysConfigService.getSysConfigContext(ConfigName.SERVICE);
        String consultationUrl = serviceMap.get("context");
        request.setAttribute("consultationUrl",consultationUrl);
        return  "/view/app/customerIndex";
    }

}
